#include <stdio.h>

#define LEN 10

char * getnchar(char * str, int n);

int main(int argc, int * argv[])
{
	char input[LEN];
	char *chk;

	chk = getnchar(input, LEN - 1);	
	
	if (chk == NULL)
		puts("Input failed.");
	else
		puts(input);
	puts("Done.\n");
	return 0;
}

char * getnchar(char * str, int n)
{
	int i;
	int ch;

	for (i = 0; i< n; i++)
	{
		ch = getchar();
		
		if (i ==0)
		{
			if (ch != ' ' && ch != '\0' && ch != EOF)
			{
				str[i] = ch;
			}
			else
			{
				ch == EOF;
			}
		}
		else
		{
			if (ch != EOF)
				str[i] = ch;
			else
				break;
		}	
	}
	if (ch == EOF)
		return NULL;
	else
	{
		str[i] = '\0';
		return str;
	}
}
